package cnsatmsmart.automation.mmi.model.data.component;

import java.io.File;
import javax.swing.filechooser.FileFilter;

public class PNGFilter extends FileFilter {
    /* const */
        public static final String PNG = "png";

    /* method - method yang dimiliki oleh kelas PNGFilter */
        public static String getExtension (File f) {
            String ext = null;
            String filename = f.getName();
            int i = filename.lastIndexOf('.');

            if ((i > 0) && (i < filename.length() - 1)) {
                ext = filename.substring(i + 1).toLowerCase();
            }

            return (ext);
        }

    @Override
    public boolean accept (File f) {
        if (f.isDirectory()) {
            return (true);
        }

        String extension = getExtension(f);
        if (extension != null) {
            if (extension.equals(PNG)) {
                return (true);
            }
        }

        return (false);
    }

    @Override
    public String getDescription () {
        return ("PNG (*.png)");
    }
}
